<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<TITLE>
Messages (Google Web Toolkit Javadoc)
</TITLE>

<META NAME="keywords" CONTENT="com.google.gwt.i18n.client.Messages interface">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
    parent.document.title="Messages (Google Web Toolkit Javadoc)";
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">


<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../com/google/gwt/i18n/client/LocalizableResource.Meaning.html" title="annotation in com.google.gwt.i18n.client"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../com/google/gwt/i18n/client/Messages.DefaultMessage.html" title="annotation in com.google.gwt.i18n.client"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../../index.html?com/google/gwt/i18n/client/Messages.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="Messages.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;<A HREF="#nested_class_summary">NESTED</A>&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;METHOD</FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;METHOD</FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
com.google.gwt.i18n.client</FONT>
<BR>
Interface Messages</H2>
<DL>
<DT><B>All Superinterfaces:</B> <DD><A HREF="../../../../../com/google/gwt/i18n/client/Localizable.html" title="interface in com.google.gwt.i18n.client">Localizable</A>, <A HREF="../../../../../com/google/gwt/i18n/client/LocalizableResource.html" title="interface in com.google.gwt.i18n.client">LocalizableResource</A></DD>
</DL>
<HR>
<DL>
<DT><PRE>public interface <B>Messages</B><DT>extends <A HREF="../../../../../com/google/gwt/i18n/client/LocalizableResource.html" title="interface in com.google.gwt.i18n.client">LocalizableResource</A></DL>
</PRE>

<P>
A tag interface that facilitates locale-sensitive, compile-time binding of
 messages supplied from various sources.Using
 <code>GWT.create(<i>class</i>)</code> to "instantiate" an interface that
 extends <code>Messages</code> returns an instance of an automatically
 generated subclass that is implemented using message templates selected based
 on locale. Message templates are based on a subset of the format used by <a
 href="http://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html">
 <code>MessageFormat</code></a>.
 
 <p>
 Locale is specified at run time using a meta tag or query string as described
 for <A HREF="../../../../../com/google/gwt/i18n/client/Localizable.html" title="interface in com.google.gwt.i18n.client"><CODE>Localizable</CODE></A>.
 </p>
 
 <h3>Extending <code>Messages</code></h3>
 To use <code>Messages</code>, begin by defining an interface that extends
 it. Each interface method is referred to as a <i>message accessor</i>, and
 its corresponding message template is loaded based on the key for that
 method. The default key is simply the unqualified name of the method, but can
 be specified directly with an <code>@Key</code> annotation or a different
 generation method using <code>@GenerateKeys</code>. Additionally, if
 plural forms are used on a given method the plural form is added as a suffix
 to the key, such as <code>widgets[one]</code> for the singular version of
 the <code>widgets</code> message. The resulting key is used to find
 translated versions of the message from any supported input file, such as
 Java properties files. For example,
 
 <blockquote><pre>public interface GameStatusMessages extends Messages {
  /**
   * @param username the name of a player
   * @param numTurns the number of turns remaining
   * @return a message specifying the remaining turns for a player
   */
  String turnsLeft(String username, int numTurns);

  /**
   * @param numPoints the number of points
   * @return a message describing the current score for the current player
   */
  String currentScore(int numPoints);
}
</pre></blockquote>
 
 expects to find properties named <code>turnsLeft</code> and
 <code>currentScore</code> in an associated properties file, formatted as
 message templates taking two arguments and one argument, respectively. For
 example, the following properties would correctly bind to the
 <code>GameStatusMessages</code> interface:
 
 <blockquote><pre>turnsLeft = Turns left for player ''{0}'': {1}
currentScore = Current score: {0}
</pre></blockquote>
 
 <p>
 The following example demonstrates how to use constant accessors defined in
 the interface above:
 
 <blockquote><pre>public void beginNewGameRound(String username) {
  GameStatusMessages messages = (GameStatusMessages) GWT.create(GameStatusMessages.class);

  // Tell the new player how many turns he or she has left.
  int turnsLeft = computeTurnsLeftForPlayer(username);
  showMessage(messages.turnsLeft(username, turnsLeft));

  // Tell the current player his or her score.
  int currentScore = computeScore(username);
  setCurrentPlayer(username);
  showMessage(messages.currentScore(currentScore));
}
</pre></blockquote>
 </p>
 
 <p>The following example shows how to use annotations to store the default strings
 in the source file itself, rather than needing a properties file (you still need
 properties files for the translated strings):
 
 <blockquote><pre>public interface GameStatusMessagesAnnot extends Messages {
  /**
   * @param username the name of a player
   * @param numTurns the number of turns remaining
   * @return a message specifying the remaining turns for a player
   */
  @DefaultMessage("Turns left for player ''{0}'': {1}")
  String turnsLeft(String username, int numTurns);

  /**
   * @param numPoints the number of points
   * @return a message describing the current score for the current player
   */
  @DefaultMessage("Current score: {0}")
  String currentScore(int numPoints);
}
</pre></blockquote>
 </p>
 
 <h3>Defining Message Accessors</h3>
 Message accessors must be of the form
 
 <pre>String methodName(<i>optional-params</i>)</pre>
 
 and parameters may be of any type. Arguments are converted into strings at
 runtime using Java string concatenation syntax (the '+' operator), which
 uniformly handles primitives, <code>null</code>, and invoking
 <code>toString()</code> to format objects.
 
 <p>
 Compile-time checks are performed to ensure that the number of placeholders
 in a message template (e.g. <code>{0}</code>) matches the number of
 parameters supplied.
 </p>
 
 <p>
 Integral arguments may be used to select the proper plural form to use for
 different locales. To do this, mark the particular argument with
 <code>@PluralCount</code> (a plural rule may be specified with
 <code>@PluralCount</code> if necessary, but you will almost never need to
 do this). The actual plural forms for the default locale can be supplied in a
 <code>@PluralText</code> annotation on the method, such as
 <code>@PluralText({"one", "You have one widget"})</code>, or they can be
 supplied in the properties file as <code>methodkey[one]=You have one widget</code>. Note
 that non-default plural forms are not inherited between locales, because the
 different locales may have different plural rules (especially <code>default</code> and
 anything else and those which use different scripts such as <code>sr_Cyrl</code> and
 <code>sr_Latn</code> [one of which would likely be the default], but also subtle cases
 like <code>pt</code> and <code>pt_BR</code>).
 </p>
 
 <p>
 Additionally, individual arguments can be marked as optional (ie, GWT will
 not give an error if a particular translation does not reference the
 argument) with the <code>@Optional</code> annotation, and an example may be supplied to
 the translator with the <code>@Example(String)</code> annotation.
 </p>
 
 <h3>Complete Annotations Example</h3>
 In addition to the default properties file, default text and additional
 metadata may be stored in the source file itself using annotations. A
 complete example of using annotations in this way is:
 
 <code><pre>
 &#64;Generate(format = "com.google.gwt.i18n.rebind.format.PropertiesFormat")
 &#64;DefaultLocale("en_US")
 public interface MyMessages extends Messages {
   &#64;Key("1234")
   &#64;DefaultText("This is a plain string.")
   String oneTwoThreeFour();
   
   &#64;DefaultText("You have {0} widgets")
   &#64;PluralText({"one", "You have one widget")
   String widgetCount(&#64;PluralCount int count);
   
   &#64;DefaultText("No reference to the argument")
   String optionalArg(&#64;Optional String ignored);
   
   &#64;DefaultText("Your cart total is {0,number,currency}")
   &#64;Description("The total value of the items in the shopping cart in local currency")
   String totalAmount(&#64;Example("$5.00") double amount);
   
   &#64;Meaning("the color")
   &#64;DefaultMessage("orange")
   String orangeColor();
   
   &#64;Meaning("the fruit")
   &#64;DefaultMessage("orange")
   String orangeFruit();
 }
 </pre></code>
 
 <h3>Binding to Properties Files</h3>
 Interfaces extending <code>Messages</code> are bound to resource files
 using the same algorithm as interfaces extending <code>Constants</code>.
 See the documentation for <A HREF="../../../../../com/google/gwt/i18n/client/Constants.html" title="interface in com.google.gwt.i18n.client"><CODE>Constants</CODE></A> for a description of the
 algorithm.
 
 <h3>Required Module</h3>
 Modules that use this interface should inherit
 <code>com.google.gwt.i18n.I18N</code>.
 
 <blockquote><pre>&lt;module&gt;
  &lt;!-- other inherited modules, such as com.google.gwt.user.User --&gt;
  &lt;inherits name="com.google.gwt.i18n.I18N"/&gt;
  &lt;!-- additional module settings --&gt;
&lt;/module&gt;
</pre></blockquote>
 
 <h3>Note</h3>
 You should not directly implement this interface or interfaces derived from
 it since an implementation is generated automatically when message interfaces
 are created using <A HREF="../../../../../com/google/gwt/core/client/GWT.html#create(java.lang.Class)"><CODE>GWT.create(Class)</CODE></A>.
<P>

<P>
<HR>

<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->

<A NAME="nested_class_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Nested Class Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;interface</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/gwt/i18n/client/Messages.DefaultMessage.html" title="annotation in com.google.gwt.i18n.client">Messages.DefaultMessage</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default text to be used if no translation is found (and also used as the
 source for translation).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;interface</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/gwt/i18n/client/Messages.Example.html" title="annotation in com.google.gwt.i18n.client">Messages.Example</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;An example of the annotated parameter to assist translators.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;interface</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/gwt/i18n/client/Messages.Optional.html" title="annotation in com.google.gwt.i18n.client">Messages.Optional</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Indicates the specified parameter is optional and need not appear in a
 particular translation of this message.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;interface</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/gwt/i18n/client/Messages.PluralCount.html" title="annotation in com.google.gwt.i18n.client">Messages.PluralCount</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Provides multiple plural forms based on a count.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;interface</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../com/google/gwt/i18n/client/Messages.PluralText.html" title="annotation in com.google.gwt.i18n.client">Messages.PluralText</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Provides multiple plural forms based on a count.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="nested_classes_inherited_from_class_com.google.gwt.i18n.client.LocalizableResource"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Nested classes/interfaces inherited from interface com.google.gwt.i18n.client.<A HREF="../../../../../com/google/gwt/i18n/client/LocalizableResource.html" title="interface in com.google.gwt.i18n.client">LocalizableResource</A></B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../../../../com/google/gwt/i18n/client/LocalizableResource.DefaultLocale.html" title="annotation in com.google.gwt.i18n.client">LocalizableResource.DefaultLocale</A>, <A HREF="../../../../../com/google/gwt/i18n/client/LocalizableResource.Description.html" title="annotation in com.google.gwt.i18n.client">LocalizableResource.Description</A>, <A HREF="../../../../../com/google/gwt/i18n/client/LocalizableResource.Generate.html" title="annotation in com.google.gwt.i18n.client">LocalizableResource.Generate</A>, <A HREF="../../../../../com/google/gwt/i18n/client/LocalizableResource.GeneratedFrom.html" title="annotation in com.google.gwt.i18n.client">LocalizableResource.GeneratedFrom</A>, <A HREF="../../../../../com/google/gwt/i18n/client/LocalizableResource.GenerateKeys.html" title="annotation in com.google.gwt.i18n.client">LocalizableResource.GenerateKeys</A>, <A HREF="../../../../../com/google/gwt/i18n/client/LocalizableResource.Key.html" title="annotation in com.google.gwt.i18n.client">LocalizableResource.Key</A>, <A HREF="../../../../../com/google/gwt/i18n/client/LocalizableResource.Meaning.html" title="annotation in com.google.gwt.i18n.client">LocalizableResource.Meaning</A></CODE></TD>
</TR>
</TABLE>
&nbsp;

<P>
<!-- ========= END OF CLASS DATA ========= -->
<HR>


<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../com/google/gwt/i18n/client/LocalizableResource.Meaning.html" title="annotation in com.google.gwt.i18n.client"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../com/google/gwt/i18n/client/Messages.DefaultMessage.html" title="annotation in com.google.gwt.i18n.client"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../../index.html?com/google/gwt/i18n/client/Messages.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="Messages.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;<A HREF="#nested_class_summary">NESTED</A>&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;METHOD</FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;METHOD</FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>

</BODY>
</HTML>
